package com.china.school.controller;

import com.china.school.User;
import com.china.school.handlermethod.Token;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    @GetMapping("")
    public User test(){
        User user = new User("小明",22);
        return user;
    }


    @GetMapping("/")
    public String success(){

        return "user";
    }

    @RequestMapping(value = "/user" )
    public String login(User user, Model model , @Token String token) {
        System.out.println(user);
        model.addAttribute("user", user);
        return "success";
    }

}
